<!doctype html>
<html lang="zh-CN" id="index">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui" />
  <meta name="apple-mobile-web-app-capable" content="yes" />
  <meta name="format-detection" content="telephone=no, email=no" />
  <meta name="keywords" content="">
  <meta name="description" content="">
  <title>图片裁剪</title>
  <style>
    body {
      margin: 0;
      text-align: center;
    }

    #clip-area {
      margin: 20px;
      height: 300px;
    }
    #file,
    #clip-btn {
      margin: 20px;
    }
    .photo-clip-view {
      background-color: #ccc;
    }
    #view {
      margin: 0 auto;
      width: 200px;
      height: 200px;
    }
    .modal {
      display: none;
      position: absolute;
      top: 50px;
      z-index: 999;
      width: 80%;
      margin-left: 10%;
      box-shadow: 2px 2px 20px rgba(0,0,0,0.2);
      border-radius: 5px;
    }
    .btn {
      display: inline-block;
      padding: 5px 30px;
      border-radius: 5px;
      border: 1px solid #eeeeee;
      cursor: pointer;
    }
    .blue {
      background-color: #2fa0f3;
      color: #ffffff;
    },
  </style>
</head>

<body>
  <label id="show-clip-modal" for="file">上传图片</label>
  <div class="modal">
    <header><h3>截取图片</h3></header>
    <div id="clip-area"></div>
    <input type="file" id="file" style="display:none">
    <div id="clip-btn" class="btn blue">截取</div>
    <div id="close-clip-modal" class="btn ">关闭</div>
  </div>
  <script src="http://www.jq22.com/jquery/2.1.1/jquery.min.js"></script>
  <script src="js/iscroll-zoom.js"></script>
  <script src="js/hammer.js"></script>
  <script src="js/lrz.all.bundle.js"></script>
  <script src="js/jquery.photoClip.js"></script>
  <script>
    $('#show-clip-modal').on('click',function () {
      $('.modal').show();
    });
    $('#close-clip-modal').on('click',function () {
      $('.modal').hide();
    });
    document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
    var clipArea = new bjj.PhotoClip("#clip-area", {
      size: [260, 260],
      file: "#file",
      ok: "#clip-btn",
      loadStart: function() {
        console.log("照片读取中");
      },
      loadComplete: function() {
        console.log("照片读取完成");
      },
      clipFinish: function(dataURL) {
        console.log(dataURL);
      }
    });
    // clipArea.destroy();
  </script>

</body>

</html>
